#encoding=utf8
'''
Created on 2012-10-17

@author: Administrator
'''
from Processor import Processor
from models.UserModel import UserModel
from pub import Func, UserDict;
from pub.Config import Config

class UFLClass(Processor):
    '''
    指令：UFL(user friend list)
    备注：好友列表
    格式：c-s:cmd #cmdID#userID
     s-c:cmd #cmdID#userID#userNickName #userPohoto#userDesc
    '''
    def __init__(self,):
        Processor.__init__(self);
        self.__userId = 0;         
        
    def dataValidtor(self, cmdContent):
        if not cmdContent:
            return False;
        paraLen = len(cmdContent);
        if paraLen == 1:      
            self.__userId = Func.strToInt(cmdContent[0], Config.I_SYS_ZERO);
            return True;        
        return False;
    def outData(self,):
        userM = UserModel();
        frindList = userM.getUserFriendsById(self.__userId);
        if not frindList:
            return False;
        sendData = []; 
        for user in frindList:                                        
            sendData.append(user.get_user_id());
            sendData.append(user.get_user_nick_name());
            sendData.append(user.get_user_photo()); 
            sendData.append(user.get_user_sign());   
            
        sendStr = self.setPackage(sendData);
        self._sockObj.sendLine(sendStr);
        return True;        
